import socket
import time

def send_test_data(data):
    """Send data to server and print response"""
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
        try:
            # Connect to server
            client_socket.connect(('127.0.0.1', 55555))
            # client_socket.connect(('47.122.126.69', 55555))

            
            # Send data
            client_socket.sendall(data.encode('utf-8'))
            
            # Receive response
            response = client_socket.recv(1024).decode('utf-8')
            print(f"Sent: {data}")
            print(f"Received: {response}")
            
        except ConnectionRefusedError:
            print("Error: Could not connect to server")
        except Exception as e:
            print(f"Error: {e}")

def run_tests():
    """Run various test cases"""
    test_cases = [
        "Test message 1",
        "Another test message",
        "Special characters: !@#$%^&*()",
        "Long message " * 100,
        ""
    ]
    
    for i, test_data in enumerate(test_cases):
        print(f"\nTest case {i + 1}")
        
        send_test_data(test_data)
        time.sleep(1)  # Add delay between tests

if __name__ == "__main__":
    run_tests()
